package com.dalin.demo.service.imple;

import com.dalin.demo.dao.ClassMapper;
import com.dalin.demo.pojo.entity.Class;
import com.dalin.demo.pojo.entity.StudentClass;
import com.dalin.demo.pojo.entity.StudentCourse;
import com.dalin.demo.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ClassServiceImpl implements ClassService {
    @Autowired
    private ClassMapper classMapper;

    @Override
    public List<Class> listClassByParams(Map<String, Object> params) {
        return classMapper.listClassByParams(params);
    }

    public Integer addClass(Class class1) {
        classMapper.insertClass(class1);
        return class1.getClassId();
    }

    public Integer updateClass(Class class1) {
        classMapper.updateClass(class1);
        return class1.getClassId();
    }

    public Integer deleteClass(int id) {
        classMapper.deleteClasses(id);
        return id;
    }
    @Override
    public void batchAddClass(List<StudentClass> studentClasses) {
        classMapper.batchInsert(studentClasses);
    }

    @Override
    public List<StudentClass> getEnrolledStudentsByCourseId(Long classId) {
        return classMapper.findStudentsByClassId(classId);
    }
    public Integer deleteStudent(int id) {
        classMapper.deleteStudentById(id);
        return id;
    }
}